package com.imooc.security.core.view;

import java.util.Map;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.web.servlet.view.AbstractView;

/**
 * 5.8.6 绑定结果视图
 */
// 为了能够通用，不弄成注解形式
public class ImoocConnectView extends AbstractView {

	/**
	 * 5.8.7 渲染视图
	 */
	@Override
	protected void renderMergedOutputModel(Map<String, Object> model, HttpServletRequest request,
			HttpServletResponse response) throws Exception {
		response.setContentType("text/html;charset=UTF-8");
		
		// 5.8.9 根据model判断绑定和解绑
		// response.getWriter().write("<h3>绑定成功</h3>");
		if (model.get("connection") == null) {
			response.getWriter().write("<h3>解绑成功</h3>");
		} else {
			response.getWriter().write("<h3>绑定成功</h3>");
		}
	}
	
}
